Skip to content

Conversation

@BinaryMuse
Copy link
Contributor

@BinaryMuse BinaryMuse commented Oct 25, 2025

This PR adds a format method to Target, allowing each target to have a different formatter. It also adds reset_format to the Builder to remove the default formatter.

Motivation

When using the with_colors method with both a console-based and a file-based log target, the control codes for the colors are included in the log file. A custom formatter can be used when using TargetKind::Dispatch, but then you lose out on the automatic file rotation that the plugin provides.

Allowing a formatter per target solves this issue with techniques like the following:

Builder::new()
    .reset_format()
    .targets([
        Target::new(TargetKind::Stderr)
        .format(
            move |out, message, record| {
                // custom colorized output here
            },
        ),
        Target::new(TargetKind::LogDir { file_name: None })
        .format(move |out, message, record| {
            // custom non-colorized output here
        }),
    ])
    .build(),

@BinaryMuse BinaryMuse requested a review from a team as a code owner October 25, 2025 17:11
@github-actions
Copy link
Contributor

github-actions bot commented Oct 26, 2025

Package Changes Through 7d4338f

There are 4 changes which include log with minor, log-js with minor, updater with minor, updater-js with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.38 2.0.39
api-example-js 2.0.34 2.0.35
log 2.7.1 2.8.0
log-js 2.7.1 2.8.0
updater 2.9.0 2.10.0
updater-js 2.9.0 2.10.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@BinaryMuse BinaryMuse force-pushed the mkt/log-format-per-target branch from b40be5d to 7d4338f Compare October 27, 2025 16:42
Copy link
Member

@FabianLars FabianLars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks again

@FabianLars FabianLars merged commit 2a625ad into tauri-apps:v2 Nov 4, 2025
16 checks passed
@BinaryMuse BinaryMuse deleted the mkt/log-format-per-target branch November 4, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants